package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zarb {
   private zcfw a;
   private zapy b;
   private static final com.aspose.cells.b.c.a.za c = new com.aspose.cells.b.c.a.za(new String[]{"style-name", "text-style-name", "name", "z-index", "x", "y", "width", "height", "end-cell-address", "text-box", "object", "object-ole", "image", "desc", "class-id", "href", "show", "actuate", "notify-on-update-of-ranges", "p", "span", "stretch", "bitmap", "solid"});

   zarb(zapy var1) {
      this.b = var1;
   }

   void a(zapz var1, String var2, int var3, int var4, zcfw var5) throws Exception {
      HashMap var6 = new HashMap();
      this.a = var5;
      if (var5.m()) {
         while(true) {
            if (!var5.l()) {
               var5.k();
               break;
            }

            switch(c.a(var5.p())) {
            case 0:
               var6.put("styleName", var5.s());
               break;
            case 1:
               var6.put("textStyleName", var5.s());
               break;
            case 2:
               var6.put("name", var5.s());
               break;
            case 3:
               var6.put("zIndex", var5.s());
               break;
            case 4:
               var6.put("x", zaqh.a(this.b.a, var5.s()));
               break;
            case 5:
               var6.put("y", zaqh.a(this.b.a, var5.s()));
               break;
            case 6:
               var6.put("width", zaqh.a(this.b.a, var5.s()));
               break;
            case 7:
               var6.put("height", zaqh.a(this.b.a, var5.s()));
               break;
            case 8:
               var6.put("end-cell-address", var5.s());
            }
         }
      }

      if (var2 != null) {
         Shape var9 = var1.a.getShapes().addAutoShape(zaqf.d(var2), var3, (Integer)var6.get("y"), var4, (Integer)var6.get("x"), (Integer)var6.get("height"), (Integer)var6.get("width"));
         this.a(var9, var6, var5);
      } else if (var5.n()) {
         var5.a();
      } else {
         zaqy var7 = new zaqy(var3, (Integer)var6.get("y"), var4, (Integer)var6.get("x"), (Integer)var6.get("height"), (Integer)var6.get("width"));
         com.aspose.cells.b.a.a.ze.a(var1.g, (Object)var7);
         var5.d();

         while(zass.a(var5)) {
            switch(c.a(var5.p().toLowerCase())) {
            case 9:
               TextBox var8 = var1.a.getShapes().b(var3, (Integer)var6.get("y"), var4, (Integer)var6.get("x"), (Integer)var6.get("height"), (Integer)var6.get("width"));
               this.a((Shape)var8, (HashMap)var6, (zcfw)var5);
               var1.g.remove(var1.g.size() - 1);
               break;
            case 10:
               var7.h = this.a();
               break;
            case 11:
               var7.h = this.a();
               break;
            case 12:
               var7.i = this.b();
               break;
            case 13:
            default:
               var5.a();
            }
         }

      }
   }

   zasb a() throws Exception {
      zasb var1 = new zasb();
      if (this.a.m()) {
         while(true) {
            if (!this.a.l()) {
               this.a.k();
               break;
            }

            switch(c.a(this.a.p().toLowerCase())) {
            case 14:
               var1.b = this.a.s();
               break;
            case 15:
               var1.c = zaqh.v(this.a.s());
               break;
            case 16:
               var1.d = zaqf.b(this.a.s());
               break;
            case 17:
               var1.e = zaqf.c(this.a.s());
               break;
            case 18:
               var1.a = this.a.s();
            }
         }
      }

      var1.f = this.a.b();
      if ("".equals(var1.f)) {
         var1.f = null;
      }

      return var1;
   }

   zapv b() throws Exception {
      zapv var1 = new zapv();
      if (this.a.m()) {
         while(true) {
            if (!this.a.l()) {
               this.a.k();
               break;
            }

            switch(c.a(this.a.p().toLowerCase())) {
            case 14:
               var1.b(this.a.s());
               break;
            case 15:
               var1.c(zaqh.v(this.a.s()));
               break;
            case 16:
               var1.a(zaqf.b(this.a.s()));
               break;
            case 17:
               var1.b(zaqf.c(this.a.s()));
            }
         }
      }

      if (this.a.n()) {
         this.a.a();
         return var1;
      } else {
         this.a.d();
         Font var2 = this.b.b.getWorksheets().j(0);
         ArrayList var3 = new ArrayList();

         while(this.a.r() != 4) {
            this.a.j();
            if (this.a.r() != 1) {
               if (this.a.r() == 3) {
                  zaqu var4 = new zaqu();
                  var4.a = this.a.s();
                  com.aspose.cells.b.a.a.ze.a(var3, (Object)var4);
               }

               this.a.a();
            } else {
               switch(c.a(this.a.p().toLowerCase())) {
               case 19:
                  this.a(var3);
                  break;
               default:
                  this.a.a();
               }
            }
         }

         this.a.h();
         var1.a = var3;
         return var1;
      }
   }

   void a(Shape var1, HashMap var2, zcfw var3) throws Exception {
      if (var3.n()) {
         var3.a();
      } else {
         var3.d();
         zara var4;
         if (var2.get("styleName") != null) {
            var4 = (zara)this.b.i.get(var2.get("styleName"));
            if (var1 != null && var4 != null) {
               this.a(var1, var4);
            }
         }

         var4 = null;
         Font var7;
         if (var2.get("textStyleName") != null) {
            zaqt var5 = (zaqt)this.b.h.get(var2.get("textStyleName"));
            if (var5 != null && var5.b != null) {
               var7 = var5.b;
            } else {
               var7 = this.b.b.getWorksheets().j(0);
            }
         } else {
            var7 = this.b.b.getWorksheets().j(0);
         }

         if (var2.get("name") != null) {
            var1.setName((String)var2.get("name"));
         }

         if (var2.get("zIndex") != null) {
            var1.setZOrderPosition(com.aspose.cells.b.a.zo.a((String)var2.get("zIndex")));
         }

         ArrayList var8 = new ArrayList();

         while(var3.r() != 4) {
            var3.j();
            if (var3.r() != 1) {
               if (var3.r() == 3) {
                  zaqu var6 = new zaqu();
                  var6.a = var3.s();
                  com.aspose.cells.b.a.a.ze.a(var8, (Object)var6);
               }

               var3.a();
            } else {
               switch(c.a(var3.p().toLowerCase())) {
               case 19:
                  this.a(var8);
                  break;
               default:
                  var3.a();
               }
            }
         }

         var3.h();
         if (var8.size() != 0) {
            this.a(var8, var1.aa(), var7);
         }

      }
   }

   void a(ArrayList var1) throws Exception {
      if (this.a.n()) {
         this.a.a();
      } else {
         String var2 = null;
         if (var1.size() != 0) {
            zaqu var3 = (zaqu)var1.get(var1.size() - 1);
            var3.a = var3.a + "\n";
            var1.set(var1.size() - 1, var3);
         }

         if (this.a.m()) {
            while(this.a.l()) {
               switch(c.a(this.a.p())) {
               case 0:
                  var2 = this.a.s();
               }
            }
         }

         this.a.d();
         Font var5 = null;
         if (var2 != null) {
            zaqt var4 = (zaqt)this.b.h.get(var2);
            if (var4 != null) {
               var5 = var4.b;
            }
         }

         while(this.a.r() != 4) {
            this.a.j();
            if (this.a.r() != 1) {
               if (this.a.r() == 3) {
                  zaqu var6 = new zaqu();
                  var6.a = this.a.s();
                  var6.b = var5;
                  com.aspose.cells.b.a.a.ze.a(var1, (Object)var6);
               }

               this.a.a();
            } else {
               switch(c.a(this.a.p().toLowerCase())) {
               case 20:
                  this.a(var1, var5);
                  break;
               default:
                  this.a.a();
               }
            }
         }

         this.a.h();
      }
   }

   void a(ArrayList var1, Font var2) throws Exception {
      if (this.a.n()) {
         this.a.a();
      } else {
         zaqu var3 = new zaqu();
         if (this.a.m()) {
            while(this.a.l()) {
               switch(c.a(this.a.p())) {
               case 0:
                  var3.b = (Font)this.b.g.get(this.a.s());
               }
            }

            this.a.k();
         }

         if (this.a.n()) {
            this.a.a();
         } else {
            StringBuilder var4 = new StringBuilder();
            this.a(var4, this.a);
            var3.a = com.aspose.cells.b.a.zr.a(var4);
            com.aspose.cells.b.a.a.ze.a(var1, (Object)var3);
         }

      }
   }

   private void a(StringBuilder var1, zcfw var2) throws Exception {
      if (var2.n()) {
         var2.a();
      } else {
         var2.d();

         while(var2.r() != 4) {
            var2.j();
            if (var2.r() == 3) {
               var1.append(var2.s());
               var2.a();
            } else if (var2.r() != 1) {
               var2.a();
            } else if (var2.n()) {
               var2.a();
            } else {
               this.a(var1, var2);
            }
         }

         var2.h();
      }
   }

   private void a(Shape var1, zara var2) throws Exception {
      zaqz var3 = var2.a;
      if (var3.a != null) {
         var1.setTextWrapped(zaqh.u(var3.a));
      }

      if (var3.k != null) {
         switch(c.a(var3.k)) {
         case 21:
            var1.f(false);
         }
      }

      if (var3.b != null || var3.c != null || var3.d != null || var3.e != null) {
         MsoTextFrame var4 = var1.getTextFrame();
         var4.c(zaqh.a(this.b.a, var3.b));
         var4.d(zaqh.a(this.b.a, var3.c));
         var4.a(zaqh.a(this.b.a, var3.d));
         var4.b(zaqh.a(this.b.a, var3.e));
         var4.setAutoMargin(false);
      }

      if (var3.f != null && var3.g != null) {
         zbtz var5 = var1.aa();
         var5.f(zaqh.r(var3.f));
         var5.e(zaqh.s(var3.g));
      }

      if (this.b.j != null && this.b.j.size() > 0) {
         switch(c.a(var3.h)) {
         case 22:
            var1.getFill().setType(4);
         default:
            if (var3.j != null) {
               zapv var6 = (zapv)this.b.j.get(var3.j);
               if (var6 != null) {
                  this.a(var1, var6);
               }
            }
         }
      } else if (var3.h != null) {
         switch(c.a(var3.h)) {
         case 23:
            var1.getFill().setType(2);
            var1.getFill().getSolidFill().setColor(var3.i);
            var1.getFill().getSolidFill().setTransparency(1.0D - var3.o);
         }
      }

      if (var3.l != null && !"none".equals(var3.l)) {
         var1.getLineFormat().setWeight((double)zaqh.a(this.b.a, var3.m));
         var1.getLineFormat().setForeColor(var3.n);
         if (var3.p != null) {
            var1.getLineFormat().a(zaqh.t(var3.p));
         }

         var1.getLineFormat().setVisible(true);
      } else {
         var1.getLineFormat().setVisible(false);
      }

   }

   private void a(Shape var1, zapv var2) throws Exception {
      com.aspose.cells.a.f.zi var3 = this.b.k;
      com.aspose.cells.a.f.zh var4 = var3.a(var2.b());
      com.aspose.cells.b.a.d.zm var5 = var3.a(var4);
      byte[] var6 = new byte[(int)var4.a()];
      var5.a(var6, 0, (int)var4.a());
      var5.a();
      var1.getFillFormat().setImageData(var6);
      var1.getFillFormat().a(2);
      var1.getFillFormat().a(var2.b());
   }

   private byte[] a(zasb var1) throws Exception {
      if (var1.f != null) {
         return Encoding.getUTF8().a(var1.f);
      } else {
         return var1.c == null ? null : this.a(var1.c, false);
      }
   }

   private byte[] a(String var1, boolean var2) throws Exception {
      com.aspose.cells.a.f.zi var3 = this.b.k;
      com.aspose.cells.a.f.zh var4 = var3.a(var1);
      byte[] var5 = null;
      if (var4 == null) {
         if (var2) {
            return null;
         }

         com.aspose.cells.b.a.d.zh var6 = new com.aspose.cells.b.a.d.zh();
         com.aspose.cells.a.f.zj var7 = new com.aspose.cells.a.f.zj(var6);
         var7.b(2);
         var7.d(0);
         ArrayList var8 = new ArrayList();
         boolean var9 = false;

         for(int var10 = 0; var10 < var3.a(); ++var10) {
            String var11 = var3.a(var10).b();
            if (var11.startsWith(var1 + "/")) {
               zaqj var12;
               if (!var9) {
                  var12 = new zaqj("text/xml", "META-INF/manifest.xml");
                  com.aspose.cells.b.a.a.ze.a(var8, (Object)var12);
               }

               if (com.aspose.cells.b.a.zv.b(var11, var1 + "/")) {
                  var12 = new zaqj("application/vnd.oasis.opendocument.text", "/");
                  com.aspose.cells.b.a.a.ze.a(var8, (Object)var12);
               } else {
                  if (var3.a(var10).c()) {
                     com.aspose.cells.a.f.zh var14 = var7.a(var3.a(var10).b().substring(var1.length() + 1));
                     var14.a(DateTime.getNow());
                     var7.a(var14);
                     var7.b();
                  } else {
                     this.a(var3.a(var10), var3, var7, var1.length() + 1);
                  }

                  var12 = new zaqj("text/xml", var3.a(var10).b().substring(var1.length() + 1));
                  com.aspose.cells.b.a.a.ze.a(var8, (Object)var12);
               }
            }
         }

         if (var8.size() > 0) {
            this.a(var8, var7);
         }

         var7.f_();
         var7.a();
         if (var8.size() > 0) {
            var5 = var6.o();
         }

         var6.a();
      } else {
         com.aspose.cells.b.a.d.zm var13 = var3.a(var4);
         var5 = new byte[(int)var4.a()];
         var13.a(var5, 0, (int)var4.a());
         var13.a();
      }

      return var5;
   }

   private boolean a(byte[] var1) {
      if (var1 == null) {
         return true;
      } else {
         return var1.length > 6 && var1[0] == 86 && var1[1] == 67 && var1[2] == 76 && var1[3] == 77 && var1[4] == 84 && var1[5] == 70;
      }
   }

   private void a(com.aspose.cells.a.f.zh var1, com.aspose.cells.a.f.zi var2, com.aspose.cells.a.f.zj var3, int var4) throws Exception {
      com.aspose.cells.b.a.d.zm var5 = var2.a(var1);
      byte[] var6 = new byte[(int)var1.a()];
      var5.a(var6, 0, (int)var1.a());
      var5.a();
      com.aspose.cells.a.f.zh var7 = var3.a(var1.b().substring(var4));
      var7.a(DateTime.getNow());
      var3.a(var7);
      var3.b(var6, 0, var6.length);
      var3.b();
   }

   private void a(ArrayList var1, com.aspose.cells.a.f.zj var2) throws Exception {
      zcfx var3 = zarj.a("META-INF/manifest.xml", var2);
      var3.c();
      var3.b("manifest:manifest");
      var3.a("xmlns", "manifest", (String)null, "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");

      for(int var4 = 0; var4 < var1.size(); ++var4) {
         zaqj var5 = (zaqj)var1.get(var4);
         var3.b("manifest:file-entry");
         var3.a("manifest", "media-type", (String)null, var5.a());
         var3.a("manifest", "full-path", (String)null, var5.b());
         var3.b();
      }

      var3.b();
      var3.d();
      var3.a((int)1);
      var3.e();
   }

   private void a(ArrayList var1, zbtz var2, Font var3) {
      if (var1.size() < 0) {
         var2.a(var3);
      } else if (var1.size() == 1) {
         zaqu var9 = (zaqu)var1.get(0);
         var2.a(var9.a);
         var2.a(var9.b == null ? var3 : var9.b);
      } else {
         StringBuilder var4 = new StringBuilder();
         ArrayList var5 = new ArrayList();

         for(int var6 = 0; var6 < var1.size(); ++var6) {
            zaqu var7 = (zaqu)var1.get(var6);
            FontSetting var8 = new FontSetting(var4.length(), var7.a.length(), this.b.b.getWorksheets(), true);
            var4.append(var7.a);
            if (var7.b == null) {
               var8.getFont().c(var3);
            } else {
               var8.getFont().c(var7.b);
            }

            com.aspose.cells.b.a.a.ze.a(var5, (Object)var8);
         }

         var2.a(com.aspose.cells.b.a.zr.a(var4));
         var2.a(var3);
         var2.b(var5);
      }
   }

   void a(zapz var1) throws Exception {
      Worksheet var2 = var1.a;
      zapy var3 = var1.b;
      Font var4 = var3.b.getDefaultStyle().getFont();

      for(int var5 = 0; var5 < var1.g.size(); ++var5) {
         try {
            zaqy var6 = (zaqy)var1.g.get(var5);
            if (var6.h != null && var6.h.a()) {
               zasb var7 = var6.h;
               zcfk var8 = null;
               com.aspose.cells.b.a.d.zm var9 = null;
               if (var7.f != null && !"".equals(var7.f)) {
                  var8 = new zcfk((zcft)null);
                  var8.a(var7.f, false);
               } else {
                  String var10 = var7.c;
                  if (var10 != null && var10.endsWith("/")) {
                     var10 = var10 + "content.xml";
                  } else {
                     var10 = var10 + "/content.xml";
                  }

                  var9 = this.b.b(var10);
                  if (var9 != null) {
                     var8 = zass.a((com.aspose.cells.b.a.d.zm)var9, (zcft)null, false);
                  }
               }

               if (var8 != null) {
                  if (var8.f() != null) {
                     try {
                        zapl var19 = new zapl(this.b, var2, var6);
                        var19.a(var8);
                        continue;
                     } catch (Exception var14) {
                        ;
                     }
                  }

                  if (var9 != null) {
                     var9.a();
                  }
               }

               try {
                  byte[] var18 = this.a(var7);
                  if (var18 != null) {
                     byte[] var11 = this.a(var6.i.b(), true);
                     if (this.a(var11)) {
                        var11 = com.aspose.cells.a.c.zv.h();
                     }

                     OleObject var12 = var2.getShapes().addOleObject(var6.f, (int)var6.c, var6.g, (int)var6.b, (int)var6.d, (int)var6.e, var11);
                     var12.setObjectData(var18);
                     var12.setProgID("Word.OpenDocumentText.12");
                     if (var7.b != null) {
                        var12.a(new com.aspose.cells.b.a.zh(var7.b));
                     }
                     continue;
                  }
               } catch (Exception var13) {
                  ;
               }
            }

            if (var6.i != null) {
               byte[] var16 = this.a(var6.i.b(), true);
               if (var16 != null) {
                  if (this.a(var16)) {
                     var16 = com.aspose.cells.a.c.zv.h();
                  }

                  Picture var17 = var1.a.getShapes().a(var6.f, var6.g, new com.aspose.cells.b.a.d.zh(var16), 100, 100);
                  if (var17 != null) {
                     var17.a(var6.f, (int)var6.c, var6.g, (int)var6.b, (int)var6.d, (int)var6.e);
                     if (var6.i.a != null && var6.i.a.size() != 0) {
                        this.a(var6.i.a, var17.aa(), var4);
                     }
                  }
               }
            }
         } catch (Exception var15) {
            ;
         }
      }

   }
}
